package com.llamarun;

import android.app.Dialog;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;

public class PauseDialog extends Dialog implements OnClickListener
{
	private static final String TAG = PauseDialog.class.getSimpleName();
	OnMyDialogResult mDialogResult;
	Button restartButton;
	Button resumeButton;
	Button mainButton;
	
	public PauseDialog(Context context)
	{
		super(context);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.pause);
		
		restartButton = (Button) findViewById(R.id.restartBtn);
		restartButton.setOnClickListener(this);
		
		resumeButton = (Button) findViewById(R.id.resumeGameBtn);
		resumeButton.setOnClickListener(this);
		
		mainButton = (Button) findViewById(R.id.mainMenuBtn);
		mainButton.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v)
	{
		switch(v.getId())
		{
			case R.id.restartBtn:
				Log.d(TAG, "restartClickHandler");
				mDialogResult.finish("restart");
				dismiss();
				break;
			case R.id.resumeGameBtn:
				Log.d(TAG, "resumeClickHandler");
				mDialogResult.finish("resume");
				dismiss();
				break;
			case R.id.mainMenuBtn:
				Log.d(TAG, "mainClickHandler");
				mDialogResult.finish("main");
				dismiss();
				break;
		}
	}
	
	public void setDialogResult(OnMyDialogResult onMyDialogResult)
	{
        mDialogResult = onMyDialogResult;
    }
	
	public interface OnMyDialogResult
	{
		void finish(String result);
	}
}
